<?php
/*
 * Created on 08.01.2007
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */

m2import('phpinchains/psp/Tag.php');

class xics_caseHandler extends phpinchains_psp_Tag
{

    /**
     * Is a body tag (if false, body is ignored)
     */
    var $tagType = PSP_BODY_TAG;
    /**
     * Tag name in form namespace:tagname
     */
    var $tagName   = 'xics:case';
    /**
     * required attributes
     */
    var $requiredAttributes = array(
        'type' => '[\w\d_]+'
    );
    /**
     * allowed attributes
     */
    var $attributes = array('type');

    function doStartTag()
    {
        $parentInsert = & $this->findAncestorWithClass($this, 'xics_insertHandler');
        if ($parentInsert == null)
        {
            $this->out->write("xics:case may only be used nested in a xics:insert.");
            return PSP_SKIP_PAGE;
        }
        $varname = $parentInsert->getAttribute('var')?$parentInsert->getAttribute('var'):'data';
        $data = $this->actionform->get($varname);
        if ($this->getAttribute('type') && $data['meta']['type'] == $this->getAttribute('type'))
            return PSP_EVAL_BODY_INCLUDE;
        else
            return PSP_SKIP_BODY;
    }

}
?>